package com.winsdom.mapper.mapper;

import com.winsdom.domain.BuildingMessage;
import com.winsdom.domain.PropertyInfoMessage;
import com.winsdom.domain.dto.AddFeeDTO;
import com.winsdom.domain.vo.PropertyInfoFeeVO;
import com.winsdom.entity.Expenditure;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProjectManagementMapper {

    @Select("SELECT c.parent_id,b.*\n" +
            "FROM category c\n" +
            "JOIN building b ON c.id = b.category_id\n" +
            "WHERE c.id = #{id};")
    BuildingMessage getBuildingMessage(Long id);

    @Select("SELECT c.parent_id,p.*\n" +
            "FROM category c\n" +
            "JOIN property_info p ON c.id = p.category_id\n" +
            "WHERE c.id = #{id};")
    PropertyInfoMessage getPropertyInfoMessage(Long id);

    @Select("select b.id,e.expenditure_name,f.fee_name,c.fee_name as fee_nature,b.formula_name " +
            "from billing_association b join expenditure e ON b.expenditure_id=e.expenditure_id " +
            "JOIN fee_category f ON f.id=e.fee_category_id " +
            "JOIN fee_category c ON f.parent_id=c.id where b.expenditure_id=#{id}")
    PropertyInfoFeeVO getPropertyInfoFee(Long id);


    @Select("select e.expenditure_id,e.expenditure_name " +
            "from expenditure e join fee_category f on e.fee_category_id=f.id " +
            "join fee_category c on f.parent_id=c.id " +
            "where f.parent_id in(1,2) and e.status=1")
    List<Expenditure> getexpenditureList();

}
